﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SharpDiary.Core.Controls
{
    public partial class TagSelector : UserControl
    {
        private bool _isModified = false;

        public bool IsModified
        {
            get { return _isModified; }
            set
            {
                _isModified = value;
                OnModifiedChanged(this, EventArgs.Empty);
            }
        }

        public event EventHandler<EventArgs> ModifiedChanged;

        protected virtual void OnModifiedChanged(object sender, EventArgs e)
        {
            if (ModifiedChanged != null)
            {
                ModifiedChanged(sender, e);
            }
        }

        public string Tags
        {
            get { return txtTags.Text; }
            set { txtTags.Text = value; }
        }

        public TagSelector()
        {
            InitializeComponent();

            txtTags.ModifiedChanged += new EventHandler(txtTags_ModifiedChanged);
        }

        void txtTags_ModifiedChanged(object sender, EventArgs e)
        {
            IsModified = true;
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);

            Rectangle rect = this.ClientRectangle;
            rect.Width -= 1;
            rect.Height -= 1;

            ControlPaint.DrawVisualStyleBorder(e.Graphics, rect);
        }
    }
}
